package cn.bone.springcloud.controller;

import cn.bone.springcloud.service.IPaymentService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.UUID;

@RestController
@Slf4j
public class PaymentController {

    @Value("${server.port}")
    private String serverPort;
    @Resource
    private IPaymentService paymentService;

    @RequestMapping("/paymentInfo/success/{id}")
    public String paymentInfoSuccess(@PathVariable("id") Integer id){
        String result = paymentService.paymentInfoSuccess(id);
        log.info("paymentInfo success, port:{}\tresult:{}",serverPort,result);
        return result;
    }

    @RequestMapping("/paymentInfo/timeout/{id}")
    public String paymentInfoTimeout(@PathVariable("id") Integer id){
        String result = paymentService.paymentInfoTimeout(id);
        log.info("paymentInfo timeout, port:{}\tresult:{}",serverPort,result);
        return result;
    }

    @RequestMapping("/paymentInfo/cb/{id}")
    public String cb(@PathVariable("id")Integer id){
        return paymentService.paymentCircuitBreaker(id);
    }
}
